<template>
  <div>
<ul>
  <li v-for="(a, b) in arr" :key="a">
    {{ a }}
    <button @click="del(b)">删除</button></li>
</ul>
 <button @click="add">生成</button>
  </div>
</template>

<script>
export default {
  data () {
    return {
      arr: [3, 2, 1]
    }
  },

  created () {

  },

  methods: {
    add () {
      this.arr.push(Math.floor(Math.random() * 20))
    },
    del (index) {
      this.arr.splice(index, 1)
    }
  }
}
</script>

<style scoped lang='less'>

</style>
